package constant

import (
	
	

	
)

// Option represents an option that can be used to configure a constant.
type Option func(constant *Constant)

// ValuesMap represent a "label" to "value" map of options for a constant variable.
type ValuesMap map[string]string

func ( ValuesMap) () string {
	 := make([]string, 0, len())

	for ,  := range  {
		 = append(, )
	}

	sort.Strings()

	return strings.Join(, ",")
}

func ( ValuesMap) ( string) *sdk.StringSliceString {
	for ,  := range  {
		if  ==  {
			return &sdk.StringSliceString{Value: []string{}, Valid: true}
		}
	}

	return &sdk.StringSliceString{Value: []string{}, Valid: true}
}

// Constant represents a "constant" templated variable.
type Constant struct {
	Builder sdk.TemplateVar
	values  ValuesMap
}

// New creates a new "constant" templated variable.
func ( string,  ...Option) *Constant {
	 := &Constant{Builder: sdk.TemplateVar{
		Name:    ,
		Label:   ,
		Type:    "constant",
		Options: []sdk.Option{},
	}}

	for ,  := range  {
		()
	}

	return 
}

// Values sets the possible values for the variable.
func ( ValuesMap) Option {
	return func( *Constant) {
		for ,  := range  {
			.Builder.Options = append(.Builder.Options, sdk.Option{
				Text:  ,
				Value: ,
			})
		}

		.values = 
		.Builder.Query = .asQuery()
	}
}

// Default sets the default value of the variable.
func ( string) Option {
	return func( *Constant) {
		.Builder.Current = sdk.Current{
			Text:  .values.labelFor(),
			Value: ,
		}
	}
}

// Label sets the label of the variable.
func ( string) Option {
	return func( *Constant) {
		.Builder.Label = 
	}
}

// HideLabel ensures that this variable's label will not be displayed.
func () Option {
	return func( *Constant) {
		.Builder.Hide = 1
	}
}

// Hide ensures that the variable will not be displayed.
func () Option {
	return func( *Constant) {
		.Builder.Hide = 2
	}
}